Before.
FlowLayout
Manager
Our program will look better if it uses the FlowLayout
manager.
The FlowLayout
manager puts components into the frame
row by row in the
order they are added.
(Later on we will add more than one component).
It also picks reasonable sizes for components.
Here is how you ask for this manager:
import java.awt.*; . . . public class ButtonDemo extends JFrame { Button bChange; buttonDemo() { bChange = new Button("Click Me!"); // choose the layout manager getContentPane().setLayout( new FlowLayout() ); getContentPane().add( bChange ); } public static void main ( String[] args ) { ButtonDemo frm = new ButtonDemo(); . . . . . } }
The FlowLayout
manager
is part of the java.awt
package.